-
Notifications
You must be signed in to change notification settings - Fork 7.7k
fix: update existing route index to prevent 404 on user switch #6003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update existing route index to prevent 404 on user switch #6003
Conversation
|
WalkthroughThe update revises the internal logic of the Changes
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/effects/access/src/accessible.ts (1)
42-42
: Consider alternative to the delete operator.The static analysis tool flagged this line due to the use of the
delete
operator, which can impact performance in certain JavaScript engines.- delete route.component; + route.component = undefined;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/effects/access/src/accessible.ts
(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/effects/access/src/accessible.ts
[error] 48-48: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: post-update (windows-latest)
- GitHub Check: post-update (ubuntu-latest)
🔇 Additional comments (1)
packages/effects/access/src/accessible.ts (1)
47-54
: Excellent fix for the route update issue!This implementation effectively solves the 404 error issue that occurs when switching between users with different second-level routes under the same first-level directory. By replacing the existing route instead of ignoring it, you ensure that the homePath and other route properties are properly updated.
The implementation is robust with proper index checks (
index !== undefined && index !== -1
) before attempting to update the route. This prevents any potential runtime errors.🧰 Tools
🪛 Biome (1.9.4)
[error] 48-48: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
Description
后端访问控制路由时,切换登录账户有可能出现404错误。具体复现情况如下:
路由为两级菜单,假设
zhangsan 的菜单是
/user
/user/manage
homePath 是 /user/manage
lisi 的菜单是
/user
/user/password
homePath 是 /user/password
因为一级目录都是 /user,导致路由未更新,但是作为 homePath 的二级目录有变化,会导致登录之后出现404页面。
代码修改了 route 更新逻辑,未找到的路由仍然保持添加逻辑,找到的路由根据 index 做更新可以解决这个问题。
Type of change
Summary by CodeRabbit